<SCRIPT LANGUAGE="JavaScript">  

    function change(temp)
    {
        $("#all").fadeOut("fast");
        $("#end").fadeOut("fast");
        $("#wait").fadeOut("fast");
        $("#post").fadeOut("fast");
        
        $("#"+temp.value).slideDown("slow");
    }
    
</SCRIPT>

<?php        
e($javascript->link('jquery.js'));
echo "<div class='form'>";
    echo "<h2> Iklan Saya </h2>";
    echo "<hr color='#2A7EF7'>";

    echo $this->element('myfunction');
    echo ":. Terbitkan iklan baru ".$html->link('[ Disini ]',array('controller'=>'advs','action'=>'post'));
    echo "<br><br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Kategori : ";
    echo "<select onchange='change(this)'><option>- Pilih Kategori -</option><option value='all'> Semua Kategori </option><option value='post'> Sudah Diterbitkan </option><option value='end'> Sudah Kadaluarsa </option><option value='wait'>Menunggu Approval</option></select>";

    echo "<div id='isi'></div>";


    echo "<div id='all' style='display:none'>";
        if(!empty($all))
        {    
            foreach($all as $data)
            {
                echo "<div id='list'>";
                    echo "<table cellpadding=0 cellspacing=0><tr>";
                //echo $html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),array('controller'=>'advs','action'=>'view','id'=>$data['Adv']['id']),array(),false,false );
                    echo "<td>".$html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),$data['Adv']['link'],array(),false,false )."</td>";
                    echo "<td><div style='padding-left:20px'>";
                    if($data['Adv']['status']==1 && $data['Adv']['end_date'] >= date("Y-m-d"))
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])." - ".mydate($data['Adv']['end_date'])." <br>"; }
                    else
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])."<br>"; }
                    echo " <b>Link</b>  &nbsp  &nbsp &nbsp : <a href='".$data['Adv']['link']."' class='sky'>".$data['Adv']['link']."</a><br>";
                        if($data['Adv']['status']==0)
                        { 
                            if($data['Adv']['slip']=='')
                            { echo " <b>Status</b> &nbsp : Menunggu Pembayaran <br>"; }
                            else
                            { echo " <b>Status</b> &nbsp : Menunggu Aktifasi <br>"; }
                            echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp";
                            echo $html->link('[ Edit ]',array('controller'=>'advs','action'=>'edit','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Pembayaran ]',array('controller'=>'advs','action'=>'payment','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Are you sure?" ); 

                        }
                        else
                        {
                            if($data['Adv']['end_date'] >= date("Y-m-d"))
                            { echo " <b>Status</b> &nbsp : Sudah Diterbitkan <br>"; }
                            else
                            { 
                                echo " <b>Status</b> &nbsp : Kadaluarsa <br>"; 
                                echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp"; 
                                echo $html->link('[ Terbitkan Kembali ]',array('controller'=>'advs','action'=>'repost','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda harus melakukan pembayaran kembali. Anda yakin ?" ); 
                                echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin ?" ); 
                            } 
                        }
                    echo "</div></td>";
                    echo "</tr></table>";
                        
                echo "</div>";
            }
        }
        else
        { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* Tidak ada iklan pada kategori yang anda pilih</span>"; }
    echo "</div>";

    echo "<div id='post' style='display:none'>";
        if(!empty($post))
        {    
            foreach($post as $data)
            {
                echo "<div id='list'>";
                    echo "<table cellpadding=0 cellspacing=0><tr>";
                    echo "<td>".$html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),$data['Adv']['link'],array(),false,false )."</td>";
                    echo "<td><div style='padding-left:20px'>";
                    if($data['Adv']['status']==1 && $data['Adv']['end_date'] >= date("Y-m-d"))
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])." - ".mydate($data['Adv']['end_date'])." <br>"; }
                    else
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])."<br>"; }
                    echo " <b>Link</b>  &nbsp  &nbsp &nbsp : <a href='".$data['Adv']['link']."' class='sky'>".$data['Adv']['link']."</a><br>";
                        if($data['Adv']['status']==0)
                        { 
                            if($data['Adv']['slip']=='')
                            { echo " <b>Status</b> &nbsp : Menunggu Pembayaran <br>"; }
                            else
                            { echo " <b>Status</b> &nbsp : Menunggu Aktifasi <br>"; }
                            echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp";
                            echo $html->link('[ Edit ]',array('controller'=>'advs','action'=>'edit','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Pembayaran ]',array('controller'=>'advs','action'=>'payment','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin ?" ); 

                        }
                        else
                        {
                            if($data['Adv']['end_date'] >= date("Y-m-d"))
                            { echo " <b>Status</b> &nbsp : Sudah Diterbitkan <br>"; }
                            else
                            { 
                                echo " <b>Status</b> &nbsp : Kadaluarsa <br>"; 
                                echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp"; 
                                echo $html->link('[ Terbitkan Kembali ]',array('controller'=>'advs','action'=>'repost','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda harus melakukan pembayaran kembali. Anda yakin ?" ); 
                                echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin ?" ); 
                            } 
                        }
                    echo "</div></td>";
                    echo "</tr></table>";
                        
                echo "</div>";
            }
        }
        else
        { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* Tidak ada iklan pada kategori yang anda pilih</span>"; }    
    echo "</div>";
        
    echo "<div id='end' style='display:none'>";
        if(!empty($end))
        {    
            foreach($end as $data)
            {
                echo "<div id='list'>";
                        //echo $html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),array('controller'=>'advs','action'=>'view','id'=>$data['Adv']['id']),array(),false,false );
                    echo "<table cellpadding=0 cellspacing=0><tr>";
                    echo "<td>".$html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),$data['Adv']['link'],array(),false,false )."</td>";
                    echo "<td><div style='padding-left:20px'>";
                    if($data['Adv']['status']==1 && $data['Adv']['end_date'] >= date("Y-m-d"))
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])." - ".mydate($data['Adv']['end_date'])." <br>"; }
                    else
                    { echo " <b>Tanggal Dibuat</b> : ".mydate($data['Adv']['created'])."<br>"; }
                    echo " <b>Link</b>  &nbsp  &nbsp &nbsp : <a href='".$data['Adv']['link']."' class='sky'>".$data['Adv']['link']."</a><br>";
                        if($data['Adv']['status']==0)
                        { 
                            if($data['Adv']['slip']=='')
                            { echo " <b>Status</b> &nbsp : Menunggu Pembayaran <br>"; }
                            else
                            { echo " <b>Status</b> &nbsp : Menunggu Aktifasi <br>"; }
                            echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp";
                            echo $html->link('[ Edit ]',array('controller'=>'advs','action'=>'edit','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Pembayaran ]',array('controller'=>'advs','action'=>'payment','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Are you sure?" ); 

                        }
                        else
                        {
                            if($data['Adv']['end_date'] >= date("Y-m-d"))
                            { echo " <b>Status</b> &nbsp : Sudah Diterbitkan <br>"; }
                            else
                            { 
                                echo " <b>Status</b> &nbsp : Kadaluarsa <br>"; 
                                echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp"; 
                                echo $html->link('[ Terbitkan Kembali ]',array('controller'=>'advs','action'=>'repost','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda harus melakukan pembayaran kembali. Anda yakin ?" ); 
                                echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin ?" ); 
                            } 
                        }
                    echo "</div></td>";
                    echo "</tr></table>";
                        
                echo "</div>";
            }
        }
        else
        { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* Tidak ada iklan pada kategori yang anda pilih</span>"; }
    echo "</div>";
    
    echo "<div id='wait' style='display:none'>";
        if(!empty($wait))
        {    
            foreach($wait as $data)
            {
                echo "<div id='list'>";
                        //echo $html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),array('controller'=>'advs','action'=>'view','id'=>$data['Adv']['id']),array(),false,false );
                    echo "<table cellpadding=0 cellspacing=0><tr>";
                    echo "<td>".$html->link($html->image('../'.$data['Adv']['image'],array('class'=>'adv')),$data['Adv']['link'],array(),false,false )."</td>";
                    echo "<td><div style='padding-left:20px'>";
                    if($data['Adv']['status']==1 && $data['Adv']['end_date'] >= date("Y-m-d"))
                    { echo " <b>Created</b> : ".mydate($data['Adv']['created'])." - ".mydate($data['Adv']['end_date'])." <br>"; }
                    else
                    { echo " <b>Created</b> : ".mydate($data['Adv']['created'])."<br>"; }
                    echo " <b>Link</b>  &nbsp  &nbsp &nbsp : <a href='".$data['Adv']['link']."' class='sky'>".$data['Adv']['link']."</a><br>";
                        if($data['Adv']['status']==0)
                        { 
                            if($data['Adv']['slip']=='')
                            { echo " <b>Status</b> &nbsp : Menunggu Pembayaran <br>"; }
                            else
                            { echo " <b>Status</b> &nbsp : Menunggu Aktifasi <br>"; }
                            echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp";
                            echo $html->link('[ Edit ]',array('controller'=>'advs','action'=>'edit','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Pembayaran ]',array('controller'=>'advs','action'=>'payment','id'=>$data['Adv']['id']),array('class'=>'sky') );
                            echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin?" ); 

                        }
                        else
                        {
                            if($data['Adv']['end_date'] >= date("Y-m-d"))
                            { echo " <b>Status</b> &nbsp : Sudah Diterbitkan <br>"; }
                            else
                            { 
                                echo " <b>Status</b> &nbsp : Kadaluarsa <br>"; 
                                echo " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp"; 
                                echo $html->link('[ Terbitkan Kembali ]',array('controller'=>'advs','action'=>'repost','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda harus melakukan pembayaran kembali. Anda yakin?" ); 
                                echo " &nbsp ".$html->link('[ Batal ]',array('controller'=>'advs','action'=>'delete','id'=>$data['Adv']['id']),array('class'=>'sky'),"Anda yakin?" ); 
                            } 
                        }
                    echo "</div></td>";
                    echo "</tr></table>";
                        
                echo "</div>";
            }
        }
        else
        { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* Tidak ada iklan pada kategori yang anda pilih</span>"; }
    echo "</div>";

echo "</div>";                                                     
?>